﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BioPatMLEditor;
using BioPatMLEditor.SearchControl;
using System.IO;
using QUT.Bio.BioPatML.Patterns;
using QUT.Bio.BioPatML.Alphabets;

namespace BioPatML.Test {
	[TestClass]
	public class TestEditor {
		private IPattern CreateMotif ( string pattern = "attata" ) {
			return new Motif( "", AlphabetType.DNA, pattern, 1.0 );
		}

		private IPattern CreateSimpleSeries ( string pattern = "attata" ) {
			Series series = new SeriesAll();
			series.Add( new Motif( "", AlphabetType.DNA, pattern, 1.0 ) );
			return series;
		}

		private IPattern CreateSeriesLikePromoter (
			string pattern1 = "attata",
			int gapMin = 1,
			int gapMax = 20,
			string pattern2 = "tgtcaa"
		) {
			Series series = new SeriesAll();
			series.Add( new Motif(
				name: "",
				alphabetType: AlphabetType.DNA,
				motif: pattern1,
				threshold: 1.0
			) );
			series.Add( new Gap(
				name: "",
				minLength: gapMin,
				maxLength: gapMax,
				incLength: 1
			) );
			series.Add( new Motif(
				name: "",
				alphabetType: AlphabetType.DNA,
				motif: pattern1,
				threshold: 1.0
			) );
			return series;
		}

		[TestInitialize]
		public void Init () {
			SequenceManager.Instance.Sequences.Clear();
		}

		[TestMethod]
		public void TestMethod1 () {
			OpenFileDialog dialog = new OpenFileDialog {
			    Filter = "*.*|*.*"
			};

			if ( (bool) dialog.ShowDialog() ) {
				FileInfo file = dialog.File;
				SequenceManager.Instance.LoadGenbank( file );
				Assert.AreEqual( SequenceManager.Instance.Sequences[0].Sequence.Length, 1042519 );
			}
			else {
				Assert.Inconclusive();
			}
		}
	}
}